import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '../constant';
import { CustomAppRouteRecordRaw } from '/@/script/types/Route';


const modules = import.meta.globEager('./modules/**/*.ts');

const routeModuleList: CustomAppRouteRecordRaw[] = [];

Object.keys(modules).forEach((key) => {
  const mod = modules[key].default || {};
  const modList = Array.isArray(mod) ? [...mod] : [mod];
  routeModuleList.push(...modList);
});

export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList];
// console.log("asyncRoutes", asyncRoutes)
export const RootRoute: CustomAppRouteRecordRaw = {
  path: '/',
  name: 'Root',
  redirect: '/home',
  hidden: true,
  meta: {
    title: 'Root',
  },
};

export const LoginRoute: CustomAppRouteRecordRaw = {
  path: '/login',
  name: 'Login',
  hidden: true,
  component: () => import('/@/views/sys/login/Login.vue'),
  meta: {
    title: '登录'
  },
};

// 基础路由 不用权限
export const basicRoutes = [LoginRoute, RootRoute, REDIRECT_ROUTE, ...asyncRoutes];
